Traits: Composable Units of Behaviour

نویسندگان

  • Nathanael Schärli
  • Stéphane Ducasse
  • Oscar Nierstrasz
  • Andrew P. Black
چکیده

Inheritance is the fundamental reuse mechanism in object-oriented programming languages; its most prominent variants are single inheritance, multiple inheritance, and mixin inheritance. In the first part of this paper, we identify and illustrate the conceptual and practical reusability problems that arise with these forms of inheritance. We then present a simple compositional model for structuring object-oriented programs, which we call traits. Traits are essentially groups of methods that serve as building blocks for classes and are primitive units of code reuse. In this model, classes are composed from a set of traits by specifying glue code that connects the traits together and accesses the necessary state. We demonstrate how traits overcome the problems arising with the different variants of inheritance, we discuss how traits can be implemented effectively, and we summarize our experience applying traits to refactor an existing class hierarchy.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Traits: Composable Units of Behavior

Inheritance is the fundamental reuse mechanism in object-oriented programming languages; its most prominent variants are single inheritance, multiple inheritance, and mixin inheritance. In the first part of this paper, we identify and illustrate the conceptual and practical reusability problems that arise with these forms of inheritance. We then present a simple compositional model for structur...

متن کامل

Objective-COP: Objective Context Oriented Programming

This paper introduces a context-oriented component-based application MDA (COCA-MDA) that modularizes the application’s context-dependent behaviour into context-oriented components. The components separate the application’s functional concerns from the extra-functional concerns. The application is organized into two casually connected layers: the base layer, which provides the application’s core...

متن کامل

Determining the effect of auditors' skeptical personality traits with considering the characteristics of organizational behaviour on job Audit Durability

The problem of desertion the effective and efficient staff and specialist staff is one of serious problem has been created for the organizations managers that seek to maintain, improve and utilize their human resources. Researchers believe that staff desertion will have a negative impact on the organization and not only reduce the organizational performance, but also increase the direct and ind...

متن کامل

Reusing and Composing Tests with Traits

Single inheritance often forces developers to duplicate code and logic. This widely recognized situation affects both business code and tests. In a large and complex application whose classes implement many groups of methods (protocols), duplication may also follow the application’s idiosyncrasies, making it difficult to specify, maintain, and reuse tests. The research questions we faced are (i...

متن کامل

On Traits and Types in a Java-like Setting

Both single and multiple class-based inheritance are often inappropriate as a reuse mechanism, because classes play two competing roles. Namely, a class is both a generator of instances and a unit of reuse. Traits are composable pure units of behavior reuse, consisting only of methods, that have been proposed as an add-on to single class-based inheritance in order to improve reuse. However, ado...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2003